#pragma once

#include <string>
#include <vector>

#include <websocketpp/server.hpp>

enum sqlType{
    INSERT = 0,
    UPDATE,
    SELECT,
};

struct sqlEvent {
    std::string sql;          // 包含?占位符的SQL语句
    sqlType type;             // 操作类型
    void* userData;           // 用户数据
    std::vector<std::string> params; // 参数列表，与SQL中的?一一对应
};

struct CampusSqlInfo{
    std::string sql;
    void* user_data = nullptr;
    websocketpp::connection_hdl hdl;       // 客户端连接句柄

    virtual void dummpy_func(){}
};

struct CampusSqlConnectorObserver{
    virtual void onSelectSucess(std::vector<std::vector<std::pair<std::string, std::string>>> &result, CampusSqlInfo* userData) = 0;
    virtual void onSelectFail(CampusSqlInfo* userData) = 0;

    virtual void onUpdateSucess(CampusSqlInfo* userData) = 0;
    virtual void onUpdateFail(CampusSqlInfo* userData) = 0;
    
    virtual void onInsertSucess(CampusSqlInfo* userData) = 0;
    virtual void onInsertFail(CampusSqlInfo* userData) = 0;
};